package com.tuanzhang.zhw.rpc.tests.provider;

import com.tuanzhang.zhw.rpc.config.provider.ProviderConfig;
import com.tuanzhang.zhw.rpc.config.provider.RpcServerConfig;
import com.tuanzhang.zhw.rpc.service.impl.UserServiceImpl;

import java.util.ArrayList;
import java.util.List;

public class ProviderStarter {

    public static void main(String[] args) {

        new Thread(() -> {
            try {
                //提供者配置类
                ProviderConfig config = new ProviderConfig();
                config.setInterfaceName("com.tuanzhang.zhw.rpc.service.UserService");

                config.setRef(UserServiceImpl.class.newInstance());

                //把所有的config
                List<ProviderConfig> providerConfigList =new ArrayList<>();
                providerConfigList.add(config);

                RpcServerConfig serverConfig =new RpcServerConfig(providerConfigList);
                serverConfig.setPort(8756);
                serverConfig.exporter();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }).start();
    }
}
